﻿using System;
using System.Linq;
using System.Xml.Linq;

namespace _135_将XML转换为元组_LINQ语法
{
    class Program
    {
        static void Main(string[] args)
        {
            XElement xml我的 = new XElement("Items",
                new XElement("Item",
                new XAttribute("Val1", 100),
                new XAttribute("Val2", 250)),
                new XElement("Item",
                new XAttribute("Val1", 7500),
                new XAttribute("Val2", 900)),
                new XElement("Item",
                new XAttribute("Val1", 2003),
                new XAttribute("Val2",6230))
                );

              Console.WriteLine("原状：\n{0}",xml我的);

            var 查询 = from el in xml我的.Elements("Item")
                     let v1=Convert.ToInt32(el.Attribute("Val1").Value)
                     let v2 = Convert.ToInt32(el.Attribute("Val2").Value)
                     select (Value_1: v1, Value_2: v2);

            Console.WriteLine("\n\n转化为元组后：\n");
            foreach (var item in 查询)
            {
                Console.WriteLine($"Value 1: {item.Value_1}\nValue2:{item.Value_2}\n");
            }
        }
    }
}
